﻿using BugTracker_415.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace BugTracker_415.Controllers
{
    public class HomeController : Controller
    {
        public int Sayhello()
        {
            return 555;
        }

        public ActionResult Index()
        {
            HomeIndexVm hVm = new HomeIndexVm();
            hVm.Greeting = "WorkItem Listing";
            hVm.WorkItemList = DataHolder.myWorkItemList;
            return View(hVm);
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            HomeIndexVm hVm = new HomeIndexVm();
            hVm.Greeting = "WorkItem Listing";
            hVm.WorkItemList = DataHolder.myWorkItemList
                        .Where(c => c.GetType().Name == "Bug")
                        .ToList();
            return View(hVm);
        }
        [HttpPost]
        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            HomeIndexVm hVm = new HomeIndexVm();
            hVm.Greeting = "WorkItem Listing";
            hVm.WorkItemList = DataHolder.myWorkItemList
                        .Where(c => c.GetType().Name == "TaskToDo")
                        .ToList();
            return View(hVm);
        }
    }
}